require "testcasedoc"

module LWA
  class Snippet
    attr_reader :steps

    def initialize(snippet_element)
      @snippet_file, @snippet_id = snippet_element.attributes["target"].split(".")
      @valueset_file, @valueset_id = snippet_element.attributes["value"].split(".")
      @steps = create_step_list
    end

    private 

    def create_step_list
      step_list = TestCaseDoc.new(@snippet_file.insert(-1, ".xml")).get_case(@snippet_id).create_step_list
      if @valueset_file != nil
        value_set = YAML.load_file("..\\testcase\\#{@valueset_file}.yaml")
        step_list.each do |each_step|
          each_step.value = value_set[@valueset_id.to_i][each_step.id.to_i]
        end
      end
      return step_list
    end

  end
end